﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.ComponentModel.Composition;

namespace Dynamic_UI_Framework
{
    [Export(typeof(UserControlBenchAdapter))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class UserControlBenchAdapter : AdapterBase<IBench, UserControl>
    {
        protected override void Adapt(IBench bench, UserControl target)
        {
            bench.Target = target;
            (bench as Bench).CurrentItemChanged += (s, e) => {
                (target as UserControl).Content = (bench as Bench).CurrentItem.Target;
            };

            bench.Initalize();
        }

        protected override IBench Create()
        {
            return new Bench();
        }
    }
}
